<?php
//调用文件
require "vendor/autoload.php";
//PDO连接数据库
$obj = new PDO("mysql:host=localhost;dbname=miss",'root','root');
//使用文件
use QL\QueryList;
//采集数据
$urlres = array(
"author" => array(".inner>dl>dd>ul>.zz>a","text"),
"title"  => array(".inner>dl>dd>ul>li>strong>a","text")
);
//采集地址
$url = "http://all.17k.com/lib/book.html/";
$data = QueryList::Query($url,$urlres)->data;
//循环入库
for($i=0;$i<20;$i++)
{
$title = $data[$i]["title"];
$link = $data[$i]["author"];
//入库sql语句
$sql = "insert into caiji set link='{$link}',title='{$title}'";
//运行sql
$obj->exec($sql);
}
?>
